/**
 * @date 2005-12-27 14:10:08
 *
 */
package org.nanhill.xsheet.xdata;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.nanhill.xsheet.xdata.model.XDataModel;
import org.nanhill.xsheet.xdata.output.xml.XDataDefaultXmlOutputBuilder;
import org.nanhill.xsheet.xdata.output.xml.XDataXmlOutputBuilder;

/**
 * @author alin
 * 
 */
public class XDataHelper {
	private static final Log logger = LogFactory.getLog(XDataHelper.class);

	public static Document model2Xml(XDataModel model)
			throws XDataParseException {
		XDataXmlOutputBuilder outputBuilder = new XDataDefaultXmlOutputBuilder();
		outputBuilder.setXDataModel(model);
		try {
			outputBuilder.construct();
		} catch (Exception e) {
			throw new XDataParseException(e);
		}
		logger.debug("data xml:\n" + outputBuilder.getProduct().asXML());
		return outputBuilder.getProduct();
	}
}
